package com.sig.formes;

import java.util.List;

import android.opengl.Matrix;

public abstract class Forme implements IForme{
	
	protected boolean cree = false;
	
	protected volatile float angle = 0.0f;
	protected volatile float[] color;

	private final static float[] mRotationMatrix = new float[16];

	public static float bleu[] = { 0.0f, 0.0f, 0.8f, 1.0f };
	public static float blanc[] = { 1f, 1f, 1f, 1.0f };
	public static float jaune[] = { 1f, 0f, 1f, 1.0f };
	public static float rouge[] = { 1f, 0f, 0f, 1.0f };
	public static float rose[] = { 1f, 0.8f, 0.8f, 1.0f };

	public void recreer(){
		this.cree = false;
	}
	
	public float[] getColor(){
		return this.color;
	}
	public void setColor(float[] color){
		this.color = color;
	}

	public float getAngle(){
		return this.angle;
	}
	public void setAngle(float angle){
		this.angle = angle;
	}
	public void addAngle(float angle){
		this.angle += angle;
	}

	public void draw(float[] mMVPMatrix){
		Matrix.setIdentityM(mRotationMatrix, 0);

		if(getAngle() != 0){
			Matrix.setRotateM(mRotationMatrix, 0, getAngle(), 0, 0, -1.0f);
			Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0);
		}
	}
	
	
	

	public static void ajouterFormes(List<IForme> formes){

		//segments.add( new Segment(new Point(0,0),new Point(0,1)) );		  

		formes.add(
				new Polyedre(Forme.bleu,
						new Point(0.60f,1.0f),
						new Point(-0.6f,1.0f),
						new Point(-0.6f,0.4f),
						new Point(0.60f,0.4f)
						));

		formes.add(
				new Polyedre(Forme.blanc,
						new Point(0.6f,0.4f),
						new Point(-0.60f,0.4f),
						new Point(-0.6f,-0.2f),
						new Point(0.6f,-0.2f)
						));


		formes.add(
				new Polyedre(Forme.jaune,
						new Point(0.1f,0.3f),
						new Point(-0.10f,0.3f),
						new Point(-0.2f,0.1f),
						new Point(-0.1f,-0.1f),
						new Point(0.1f,-0.1f),
						new Point(0.2f,0.1f)

						));

		formes.add(
				new Polyedre(Forme.rouge,
						new Point(0.6f,-0.2f),
						new Point(-0.6f,-0.2f),
						new Point(-0.6f,-0.8f),
						new Point(0.6f,-0.8f)
						));

		

	}
	
	public static void ajouterBite(List<IForme> formes){
		//la bite 
				formes.add(
						new Polyedre(
								Forme.rose,
								new Point(0.0f, 0.0f),
								new Point(-0.4f, 0.0f),
								new Point(-0.5f,0.1f),
								new Point(-0.4f,0.2f),
								new Point(0.0f,0.2f),
								new Point(0.1f,0.3f),
								new Point(0.2f,0.3f),
								new Point(0.3f,0.2f),
								new Point(0.3f,0.1f),
								new Point(0.2f,0.05f),
								new Point(0.3f,-0.05f),
								new Point(0.3f,-0.15f),
								new Point(0.2f,-0.25f),
								new Point(0.1f,-0.25f)

										)
						);
	}
}
